import java.util.Scanner;

public class Del implements func {
    public void work(BookList bookList){
        System.out.println("删除图书");
        Show show = new Show();
        show.work(bookList);

        System.out.println("请输入要删除图书的名称");
        Scanner scanner = new Scanner(System.in);
        String name = scanner.nextLine();
        int size = bookList.getSize();
        int mark = -1;
        for(int i = 0 ; i < size-1; i++) {
            if(name.equals(bookList.books[i].getName())){
                bookList.books[i] = bookList.books[i+1];
                mark = i;
                System.out.println("删除成功");
                System.out.println(bookList.books[i]);

            }
        }

        bookList.books[size-1] = null;
        size--;
        bookList.setSize(size);
        show.work(bookList);
        if(mark==-1){
        System.out.println("不存在此书");
    }
    }
}
